home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / access4g / filerena.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-08-22  |  15.3 KB  |  498 lines

  1. VERSION 5.00
  2. Begin VB.Form FileRenamer 
  3.    Caption         =   "File-Renamer"
  4.    ClientHeight    =   5385
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   7200
  8.    Icon            =   "FileRenamer.frx":0000
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   359
  11.    ScaleMode       =   3  'Pixel
  12.    ScaleWidth      =   480
  13.    StartUpPosition =   2  'CenterScreen
  14.    Begin VB.CommandButton Command5 
  15.       Caption         =   "Stop scroll"
  16.       Height          =   240
  17.       Left            =   360
  18.       TabIndex        =   25
  19.       Top             =   450
  20.       Width           =   1365
  21.    End
  22.    Begin VB.Timer Timer1 
  23.       Interval        =   1
  24.       Left            =   2430
  25.       Top             =   2880
  26.    End
  27.    Begin VB.PictureBox Picture1 
  28.       BackColor       =   &H00C00000&
  29.       Height          =   330
  30.       Left            =   45
  31.       ScaleHeight     =   18
  32.       ScaleMode       =   3  'Pixel
  33.       ScaleWidth      =   291
  34.       TabIndex        =   23
  35.       Top             =   45
  36.       Width           =   4425
  37.       Begin VB.Label Label7 
  38.          AutoSize        =   -1  'True
  39.          BackColor       =   &H00C00000&
  40.          Caption         =   "Label7"
  41.          BeginProperty Font 
  42.             Name            =   "MS Sans Serif"
  43.             Size            =   9.75
  44.             Charset         =   0
  45.             Weight          =   700
  46.             Underline       =   0   'False
  47.             Italic          =   0   'False
  48.             Strikethrough   =   0   'False
  49.          EndProperty
  50.          ForeColor       =   &H00FFC0C0&
  51.          Height          =   240
  52.          Left            =   180
  53.          TabIndex        =   24
  54.          Top             =   0
  55.          Width           =   720
  56.       End
  57.    End
  58.    Begin VB.CommandButton Command4 
  59.       Caption         =   "Rename !"
  60.       BeginProperty Font 
  61.          Name            =   "MS Sans Serif"
  62.          Size            =   12
  63.          Charset         =   0
  64.          Weight          =   700
  65.          Underline       =   0   'False
  66.          Italic          =   0   'False
  67.          Strikethrough   =   0   'False
  68.       EndProperty
  69.       Height          =   375
  70.       Left            =   2475
  71.       TabIndex        =   20
  72.       Top             =   4950
  73.       Width           =   1770
  74.    End
  75.    Begin VB.CommandButton Command3 
  76.       Caption         =   "Preview"
  77.       Height          =   240
  78.       Left            =   90
  79.       TabIndex        =   19
  80.       Top             =   2700
  81.       Width           =   2085
  82.    End
  83.    Begin VB.ListBox List1 
  84.       BackColor       =   &H00E0E0E0&
  85.       Height          =   2400
  86.       Left            =   90
  87.       TabIndex        =   18
  88.       Top             =   2970
  89.       Width           =   2085
  90.    End
  91.    Begin VB.CommandButton Command2 
  92.       Caption         =   "Select none -->"
  93.       Height          =   285
  94.       Left            =   3195
  95.       TabIndex        =   17
  96.       Top             =   3015
  97.       Width           =   1230
  98.    End
  99.    Begin VB.CommandButton Command1 
  100.       Caption         =   "Select all      -->"
  101.       Height          =   285
  102.       Left            =   3195
  103.       TabIndex        =   16
  104.       Top             =   2700
  105.       Width           =   1230
  106.    End
  107.    Begin VB.Frame Frame1 
  108.       Caption         =   "File Operations"
  109.       BeginProperty Font 
  110.          Name            =   "MS Sans Serif"
  111.          Size            =   9.75
  112.          Charset         =   0
  113.          Weight          =   700
  114.          Underline       =   0   'False
  115.          Italic          =   0   'False
  116.          Strikethrough   =   0   'False
  117.       EndProperty
  118.       ForeColor       =   &H00C00000&
  119.       Height          =   1815
  120.       Left            =   45
  121.       TabIndex        =   6
  122.       Top             =   765
  123.       Width           =   4425
  124.       Begin VB.CheckBox Check1 
  125.          Caption         =   "Adapt counter after renaming"
  126.          Height          =   240
  127.          Left            =   1620
  128.          TabIndex        =   22
  129.          Top             =   1125
  130.          Value           =   1  'Checked
  131.          Width           =   2670
  132.       End
  133.       Begin VB.HScrollBar HScroll1 
  134.          Height          =   270
  135.          Left            =   3645
  136.          Max             =   100
  137.          Min             =   1
  138.          TabIndex        =   15
  139.          Top             =   1440
  140.          Value           =   1
  141.          Width           =   420
  142.       End
  143.       Begin VB.TextBox Text3 
  144.          Height          =   285
  145.          Left            =   135
  146.          TabIndex        =   12
  147.          Text            =   "1"
  148.          Top             =   1440
  149.          Width           =   1275
  150.       End
  151.       Begin VB.OptionButton Option1 
  152.          Caption         =   "After"
  153.          Height          =   240
  154.          Index           =   2
  155.          Left            =   2385
  156.          TabIndex        =   11
  157.          Top             =   675
  158.          Width           =   1200
  159.       End
  160.       Begin VB.OptionButton Option1 
  161.          Caption         =   "Before"
  162.          Height          =   240
  163.          Index           =   1
  164.          Left            =   1260
  165.          TabIndex        =   10
  166.          Top             =   675
  167.          Width           =   1200
  168.       End
  169.       Begin VB.OptionButton Option1 
  170.          BackColor       =   &H00C0C0C0&
  171.          Caption         =   "Replace"
  172.          Height          =   240
  173.          Index           =   0
  174.          Left            =   135
  175.          TabIndex        =   9
  176.          Top             =   675
  177.          Value           =   -1  'True
  178.          Width           =   1200
  179.       End
  180.       Begin VB.TextBox Text2 
  181.          BackColor       =   &H00E0E0E0&
  182.          Height          =   285
  183.          Left            =   1305
  184.          TabIndex        =   8
  185.          Text            =   "Text2"
  186.          Top             =   315
  187.          Width           =   2040
  188.       End
  189.       Begin VB.Label Label6 
  190.          Alignment       =   2  'Center
  191.          BackColor       =   &H00E0E0E0&
  192.          BorderStyle     =   1  'Fixed Single
  193.          Caption         =   "Begin counter"
  194.          Height          =   270
  195.          Left            =   135
  196.          TabIndex        =   21
  197.          Top             =   1125
  198.          Width           =   1275
  199.       End
  200.       Begin VB.Line Line2 
  201.          BorderColor     =   &H80000009&
  202.          X1              =   45
  203.          X2              =   4380
  204.          Y1              =   1005
  205.          Y2              =   1005
  206.       End
  207.       Begin VB.Line Line1 
  208.          BorderColor     =   &H00808080&
  209.          X1              =   45
  210.          X2              =   4380
  211.          Y1              =   990
  212.          Y2              =   990
  213.       End
  214.       Begin VB.Label Label5 
  215.          Alignment       =   2  'Center
  216.          BackColor       =   &H00E0E0E0&
  217.          BorderStyle     =   1  'Fixed Single
  218.          Caption         =   "1"
  219.          Height          =   270
  220.          Left            =   3195
  221.          TabIndex        =   14
  222.          Top             =   1440
  223.          Width           =   420
  224.       End
  225.       Begin VB.Label Label4 
  226.          Alignment       =   2  'Center
  227.          BackColor       =   &H00E0E0E0&
  228.          BorderStyle     =   1  'Fixed Single
  229.          Caption         =   "Increase counter by:"
  230.          Height          =   270
  231.          Left            =   1620
  232.          TabIndex        =   13
  233.          Top             =   1440
  234.          Width           =   1545
  235.       End
  236.       Begin VB.Label Label3 
  237.          Alignment       =   2  'Center
  238.          BackColor       =   &H00E0E0E0&
  239.          BorderStyle     =   1  'Fixed Single
  240.          Caption         =   "Change name:"
  241.          Height          =   270
  242.          Left            =   90
  243.          TabIndex        =   7
  244.          Top             =   315
  245.          Width           =   1140
  246.       End
  247.    End
  248.    Begin VB.TextBox Text1 
  249.       BackColor       =   &H00C0FFFF&
  250.       ForeColor       =   &H000000FF&
  251.       Height          =   285
  252.       Left            =   5535
  253.       TabIndex        =   4
  254.       Text            =   "Text1"
  255.       Top             =   1950
  256.       Width           =   1680
  257.    End
  258.    Begin VB.DriveListBox Drive1 
  259.       BackColor       =   &H00E0E0E0&
  260.       Height          =   315
  261.       Left            =   3375
  262.       TabIndex        =   3
  263.       Top             =   405
  264.       Width           =   1095
  265.    End
  266.    Begin VB.DirListBox Dir1 
  267.       BackColor       =   &H00C0FFFF&
  268.       ForeColor       =   &H000000FF&
  269.       Height          =   1890
  270.       Left            =   4500
  271.       TabIndex        =   2
  272.       Top             =   45
  273.       Width           =   2700
  274.    End
  275.    Begin VB.FileListBox File1 
  276.       BackColor       =   &H00C0FFFF&
  277.       ForeColor       =   &H000000FF&
  278.       Height          =   2820
  279.       Left            =   4485
  280.       MultiSelect     =   2  'Extended
  281.       TabIndex        =   1
  282.       ToolTipText     =   "Use mouse, shift and control to select"
  283.       Top             =   2580
  284.       Width           =   2730
  285.    End
  286.    Begin VB.Label Label8 
  287.       Alignment       =   1  'Right Justify
  288.       BackColor       =   &H00C0FFFF&
  289.       BorderStyle     =   1  'Fixed Single
  290.       Caption         =   "Label1"
  291.       ForeColor       =   &H000000FF&
  292.       Height          =   285
  293.       Left            =   4500
  294.       TabIndex        =   26
  295.       Top             =   2265
  296.       Width           =   1350
  297.    End
  298.    Begin VB.Label Label2 
  299.       BackColor       =   &H00C0FFFF&
  300.       BorderStyle     =   1  'Fixed Single
  301.       Caption         =   "Pattern :"
  302.       ForeColor       =   &H000000FF&
  303.       Height          =   285
  304.       Left            =   4500
  305.       TabIndex        =   5
  306.       Top             =   1950
  307.       Width           =   1005
  308.    End
  309.    Begin VB.Label Label1 
  310.       Alignment       =   1  'Right Justify
  311.       BackColor       =   &H00C0FFFF&
  312.       BorderStyle     =   1  'Fixed Single
  313.       Caption         =   "Label1"
  314.       ForeColor       =   &H000000FF&
  315.       Height          =   285
  316.       Left            =   5850
  317.       TabIndex        =   0
  318.       Top             =   2265
  319.       Width           =   1350
  320.    End
  321. Attribute VB_Name = "FileRenamer"
  322. Attribute VB_GlobalNameSpace = False
  323. Attribute VB_Creatable = False
  324. Attribute VB_PredeclaredId = True
  325. Attribute VB_Exposed = False
  326. Dim X, Y, t As Integer
  327. Dim Counter As Long
  328. Dim temp, temp2, Oldfile, Newfile As String
  329. Private Sub Command1_Click() ' select all
  330. For X = File1.ListCount - 1 To 0 Step -1
  331. File1.Selected(X) = True
  332. Next X
  333. Selections
  334. Text2.SetFocus
  335. End Sub
  336. Private Sub Command2_Click() ' select none
  337. For X = File1.ListCount - 1 To 0 Step -1
  338. File1.Selected(X) = False
  339. Next X
  340. Selections
  341. Text2.SetFocus
  342. End Sub
  343. Private Sub Command3_Click() 'preview
  344. Selections
  345. If t = 0 Then
  346. temp = MsgBox("First select 1 or more files !", vbOKOnly + vbExclamation, "Renamer")
  347. Exit Sub
  348. End If
  349. Screen.MousePointer = 11
  350. List1.Clear
  351. Counter = Val(Text3.Text)
  352. For X = 0 To File1.ListCount - 1
  353. If File1.Selected(X) = True Then
  354.     GetNames
  355.     If Option1(0).Value = True Then 'replace
  356.         List1.AddItem Text2 & Format(Str(Counter), "000") & temp2
  357.         Counter = Counter + Val(Label5)
  358.     End If
  359.     If Option1(1).Value = True Then 'before
  360.         List1.AddItem Text2 & temp & Format(Str(Counter), "000") & temp2
  361.         Counter = Counter + Val(Label5)
  362.     End If
  363.     If Option1(2).Value = True Then 'after
  364.         List1.AddItem temp & Text2 & Format(Str(Counter), "000") & temp2
  365.         Counter = Counter + Val(Label5)
  366.     End If
  367. End If
  368. Next X
  369. Text2.SetFocus
  370. Screen.MousePointer = 1
  371. End Sub
  372. Private Sub Command4_Click() 'rename
  373. Selections
  374. If t = 0 Then
  375. temp = MsgBox("First select 1 or more files !", vbOKOnly + vbExclamation, "Renamer")
  376. Exit Sub
  377. End If
  378. temp = MsgBox("You're about to change the selected filenames..." & vbCr & vbCr & vbCr & "Are you sure about this ?", vbOKCancel + vbQuestion, "File-Renamer")
  379. Text2.SetFocus
  380. If temp = vbCancel Then Exit Sub
  381. List1.Clear
  382. On Error GoTo Fout
  383. Screen.MousePointer = 11
  384. Counter = Val(Text3.Text)
  385. For X = 0 To File1.ListCount - 1
  386. If File1.Selected(X) = True Then
  387.     Oldfile = File1.Path & "\" & File1.List(X)
  388.     GetNames
  389.     If Option1(0).Value = True Then 'replace
  390.         Newfile = File1.Path & "\" & Text2 & Format(Str(Counter), "000") & temp2
  391.         Name Oldfile As Newfile
  392.         Counter = Counter + Val(Label5)
  393.     End If
  394.     If Option1(1).Value = True Then 'before
  395.         Newfile = File1.Path & "\" & Text2 & temp & Format(Str(Counter), "000") & temp2
  396.         Counter = Counter + Val(Label5)
  397.     End If
  398.     If Option1(2).Value = True Then 'after
  399.         Newfile = File1.Path & "\" & temp & Text2 & Format(Str(Counter), "000") & temp2
  400.         Counter = Counter + Val(Label5)
  401.     End If
  402. End If
  403. Next X
  404. File1.Refresh
  405. Command2_Click
  406. If Check1.Value = 1 Then Text3.Text = Str(Counter)
  407. Screen.MousePointer = 1
  408. Text2.SetFocus
  409. Exit Sub
  410. Fout:
  411. File1.Refresh
  412. Command2_Click
  413. MsgBox ("File exists !" & vbCr & "Check your input...")
  414. Text2.SetFocus
  415. Screen.MousePointer = 1
  416. End Sub
  417. Private Sub Command5_Click() 'stop/restart scroll
  418. If Timer1.Enabled = True Then
  419. Timer1.Enabled = False
  420. Command5.Caption = "Restart scroll"
  421. Timer1.Enabled = True
  422. Command5.Caption = "Stop scroll"
  423. End If
  424. Text2.SetFocus
  425. End Sub
  426. Private Sub Dir1_Change()
  427. File1.Path = Dir1.Path
  428. Selections
  429. End Sub
  430. Private Sub Drive1_Change()
  431. On Error GoTo drivefout
  432. temp = Drive1.Drive
  433. Dir1.Path = Left(Drive1.Drive, 2) + "\"
  434. Debug.Print Dir1.Path
  435. Exit Sub
  436. drivefout:
  437. temp = MsgBox("Sorry, but the selected device is not ready!", vbOKOnly & vbCritical, "File-Renamer")
  438. End Sub
  439. Private Sub File1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  440. Selections
  441. Text2.SetFocus
  442. End Sub
  443. Private Sub Form_Activate()
  444. Text2.SetFocus
  445. End Sub
  446. Private Sub Form_Load()
  447. Drive1.Drive = "c:\"
  448. Dir1.Path = "c:\"
  449. File1.Path = "c:\"
  450. Selections
  451. Text1.Text = File1.Pattern
  452. List1.Clear
  453. Text2.Text = ""
  454. Label7.Left = Picture1.ScaleWidth
  455. Label7.Caption = "File-Renamer (c)1999 by Swertvaegher Stephan    a small but usefull program to rename files !... Feel free to modify    If you have any comments then drop me a line: stephan.swertvaegher@planetinternet.be       Only polite mails will be answered!               "
  456. End Sub
  457. Private Sub Selections()
  458. t = 0
  459. For X = 0 To File1.ListCount - 1
  460. If File1.Selected(X) = True Then
  461. t = t + 1
  462. End If
  463. Next X
  464. Label1.Caption = "Selected : " & t & "   "
  465. Label8.Caption = "Total files : " & File1.ListCount & "   "
  466. End Sub
  467. Private Sub GetNames()
  468. Dim tel As Integer
  469. tel = 0
  470. For Y = Len(File1.List(X)) To 1 Step -1
  471. tel = tel + 1
  472. If Mid(File1.List(X), Y, 1) = "." Then
  473.     temp2 = Right(File1.List(X), tel)
  474.     temp = Left(File1.List(X), Len(File1.List(X)) - tel)
  475. Exit For
  476. End If
  477. Next Y
  478. End Sub
  479. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  480. Cancel = True
  481. temp = MsgBox("Do you really want to quit ?", vbOKCancel + vbQuestion, "File-Renamer")
  482. If temp = vbOK Then End
  483. End Sub
  484. Private Sub HScroll1_Change()
  485. Label5.Caption = HScroll1.Value
  486. Text2.SetFocus
  487. End Sub
  488. Private Sub Text1_Change()
  489. File1.Pattern = Text1.Text
  490. Selections
  491. End Sub
  492. Private Sub Timer1_Timer()
  493. Label7.Left = Label7.Left - 3
  494. If Label7.Left < Label7.Width * -1 Then
  495. Label7.Left = Picture1.ScaleWidth
  496. End If
  497. End Sub
  498.